<template>
  <div class="container">
    <a-drawer title="个人中心" size="default" :visible="visible" @close="onClose">
      <template #extra>
        <a-button style="margin-right: 8px" @click="onClose">Cancel</a-button>
        <a-button type="primary" @click="onClose">Submit</a-button>
      </template>
      <p>Some contents...</p>
      <p>Some contents...</p>
      <p>Some contents...</p>
    </a-drawer>
    <a-layout>
      <a-layout-header :style="{}" v-show="isTopNav" class="slider-opacity TopNav">
        <div class="logo" />
        <a-menu
          v-model:selectedKeys="selectedKeys"
          theme="light"
          mode="horizontal"
          :style="{ lineHeight: '64px', flex: 8 }"
        >
          <a-menu-item key="1">首页</a-menu-item>
          <a-menu-item key="2">关于我们</a-menu-item>
          <a-menu-item key="3">合作交流</a-menu-item>
        </a-menu>
        <div class="face" @click="showDrawer"></div>
      </a-layout-header>
      <a-layout-content :style="{ marginTop: '0' }">
        <a-layout>
          <a-layout-sider
            width="150px"
            style="background: white,display:fixed"
            v-show="!isTopNav"
            class="slider-opacity slider-nav"
            collapsible
          >
            <div class="slider-logo" />
            <div class="face" @click="showDrawer"></div>
            <SliderMenu></SliderMenu>
          </a-layout-sider>
          <a-layout-content>
            <div>
              <a-carousel arrows>
                <template #prevArrow>
                  <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
                    <left-circle-outlined />
                  </div>
                </template>
                <template #nextArrow>
                  <div class="custom-slick-arrow" style="right: 10px">
                    <right-circle-outlined />
                  </div>
                </template>
                <div><h3>1</h3></div>
                <div><h3>2</h3></div>
                <div><h3>3</h3></div>
                <div><h3>4</h3></div>
              </a-carousel>
            </div>
            <div class="nav">
              <div class="nav-item" v-for="(item, index) in Contents" :key="index">
                <span></span>
                <div>{{ item }}</div>
              </div>
            </div>
            <a-divider />

            <div class="Content">
              <Content></Content>
              <a-row :wrap="true" align="middle" justify="center" :gutter="[gutters[gutterKey], gutters[vgutterKey]]">
                <a-col :span="spanList[select2 - 1]">
                  <div class="card">
                    <a-card
                      title="文章标题"
                      :bordered="true"
                      style="width: 100%"
                      class="a-card"
                      :size="sizeList[select1 - 1]"
                    >
                      文章简介文章简介文章简介文章简介文章简介文章简介
                    </a-card>
                  </div>
                </a-col>
                <a-col :span="spanList[select2 - 1]">
                  <div class="card">
                    <a-card
                      title="文章标题"
                      :bordered="true"
                      style="width: 100%"
                      class="a-card"
                      :size="sizeList[select1 - 1]"
                    >
                      文章简介文章简介文章简介文章简介文章简介文章简介
                    </a-card>
                  </div>
                </a-col>
                <a-col :span="spanList[select2 - 1]">
                  <div class="card">
                    <a-card
                      title="文章标题"
                      :bordered="true"
                      style="width: 100%"
                      class="a-card"
                      :size="sizeList[select1 - 1]"
                    >
                      文章简介文章简介文章简介文章简介文章简介文章简介
                    </a-card>
                  </div>
                </a-col>
                <a-col :span="spanList[select2 - 1]">
                  <div class="card">
                    <a-card
                      title="文章标题"
                      :bordered="true"
                      style="width: 100%"
                      class="a-card"
                      :size="sizeList[select1 - 1]"
                    >
                      文章简介文章简介文章简介文章简介文章简介文章简介
                    </a-card>
                  </div>
                </a-col>
              </a-row>
            </div>

            <div class="action">
              <a-button type="primary" @click="addContent">添加栏目</a-button>
              <a-button type="primary" @click="delContent">删除栏目</a-button>
              <a-button type="primary" @click="changeNav">改变导航栏位置</a-button>
              <div style="margin-bottom: 16px">
                <span style="margin-right: 6px">修改水平间距:</span>
                <div style="width: 100%">
                  <a-slider
                    v-model:value="gutterKey"
                    :min="0"
                    :max="Object.keys(gutters).length - 1"
                    :marks="gutters"
                    :step="null"
                  />
                </div>
              </div>
              <div style="margin-bottom: 16px">
                <span style="margin-right: 6px">修改垂直间距:</span>
                <div style="width: 100%">
                  <a-slider
                    v-model:value="vgutterKey"
                    :min="0"
                    :max="Object.keys(gutters).length - 1"
                    :marks="gutters"
                    :step="null"
                  />
                </div>
              </div>
              <!-- 更改导航栏透明度 -->
              <div style="margin-bottom: 16px">
                <span style="margin-right: 6px">修改导航栏透明度:</span>
                <div style="width: 100%">
                  <a-slider v-model:value="opacity" :min="0.5" :max="1" :step="0.1" />
                </div>
              </div>
              <!-- 更改卡片大小 -->
              <div style="margin-bottom: 16px">
                <span style="margin-right: 6px">修改文章卡片大小:</span>
                <a-radio-group v-model:value="select1">
                  <a-radio :value="1">小</a-radio>
                  <a-radio :value="2">大</a-radio>
                </a-radio-group>
              </div>
              <div style="margin-bottom: 16px">
                <span style="margin-right: 6px">修改文章卡片排版:</span>
                <a-radio-group v-model:value="select2">
                  <a-radio :value="1">1行2列</a-radio>
                  <a-radio :value="2">1行3列</a-radio>
                  <a-radio :value="3">1行4列</a-radio>
                  <a-radio :value="4">1行6列</a-radio>
                </a-radio-group>
              </div>
            </div>
          </a-layout-content>
        </a-layout>
      </a-layout-content>
      <a-layout-footer :style="{ textAlign: 'center' }">Ant Design ©2018 Created by Ant UED</a-layout-footer>
    </a-layout>
  </div>
</template>
<script lang="ts">
import {
  LeftCircleOutlined,
  RightCircleOutlined,
  MailOutlined,
  AppstoreOutlined,
  SettingOutlined,
  MenuFoldOutlined,
  MenuUnfoldOutlined,
} from '@ant-design/icons-vue'

import { defineComponent, ref, reactive, toRefs } from 'vue'
import Content from '../components/Content.vue'
import SliderMenu from '../components/Menu/SliderMenu.vue'
export default defineComponent({
  components: {
    LeftCircleOutlined,
    RightCircleOutlined,
    MenuFoldOutlined,
    MenuUnfoldOutlined,
    MailOutlined,
    AppstoreOutlined,
    SettingOutlined,
    Content,
    SliderMenu,
  },
  setup() {
    const current = ref<string[]>(['hot'])
    const Contents = ref<string[]>(['热门文章', '技术文章', '通知公告', '操作手册'])
    const gutters = ref<number[]>([8, 16, 24, 32, 40, 48])
    const gutterKey = ref<number>(0)
    const vgutterKey = ref<number>(0)
    const isTopNav = ref<boolean>(true)
    const opacity = ref<number>(0.5)
    const select1 = ref<number>(2)
    const select2 = ref<number>(2)
    const spanList = ref<number[]>([12, 8, 6, 4])
    const sizeList = ref<string[]>(['small', 'large'])
    const state = reactive({
      collapsed: false,
    })
    const toggleCollapsed = () => {
      state.collapsed = !state.collapsed
    }
    const radioStyle = reactive({
      display: 'flex',
      height: '30px',
      lineHeight: '30px',
    })
    const addContent = () => {
      Contents.value.push('新栏目')
    }
    const delContent = () => {
      Contents.value.pop()
    }

    const changeNav = () => {
      isTopNav.value = !isTopNav.value
    }

    //抽屉
    const visible = ref<boolean>(false)
    const showDrawer = () => {
      visible.value = true
    }

    const onClose = () => {
      visible.value = false
    }

    return {
      visible,
      showDrawer,
      onClose,
      current,
      Contents,
      addContent,
      delContent,
      gutters,
      gutterKey,
      vgutterKey,
      selectedKeys: ref<string[]>(['2']),
      isTopNav,
      changeNav,
      opacity,
      radioStyle,
      select1,
      sizeList,
      select2,
      spanList,
      ...toRefs(state),
      toggleCollapsed,
    }
  },
})
</script>
<style scoped>
.container {
  width: 100%;
  height: 100%;
}
.logo {
  width: 120px;
  height: 31px;
  background: rgba(65, 17, 238, 0.2);
  margin: 16px 24px 16px 0;
  float: left;
}

.slider-logo {
  height: 32px;
  margin: 16px;
  background: rgba(65, 17, 238, 0.2);
}

.TopNav {
  position: fixed;
  z-index: 1;
  width: 100%;
  background: white;
  display: flex;
  align-items: center;
}

.slider-nav {
  display: flex;
  flex-direction: column;
  background-color: #fff;
}

.slider-nav .face {
  margin: 10px auto;
}

.slider-opacity {
  opacity: v-bind(opacity);
}
.site-layout .site-layout-background {
  background: #fff;
}

[data-theme='dark'] .site-layout .site-layout-background {
  background: #141414;
}
/* For demo */
.ant-carousel :deep(.slick-slide) {
  text-align: center;
  height: 250px;
  line-height: 250px;
  background: #364d79;
  overflow: hidden;
}

.ant-carousel :deep(.slick-arrow.custom-slick-arrow) {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  opacity: 0.3;
  z-index: 1;
}
.ant-carousel :deep(.custom-slick-arrow:before) {
  display: none;
}
.ant-carousel :deep(.custom-slick-arrow:hover) {
  opacity: 0.5;
}

.ant-carousel :deep(.slick-slide h3) {
  color: #fff;
}
.nav {
  width: 50%;
  margin: 0 auto;
  height: 50px;
  display: flex;
  justify-content: space-around;
  margin-top: 10px;
}
.nav-item {
  height: 50px;
  padding: 0 10px;
  line-height: 50px;
  color: #1890ff;
  font-size: 20px;
}
.nav-item:hover {
  background-color: #1890ff;
  color: white;
}
.Content {
  width: 90%;
  margin: 0 auto;
}
.a-card:hover {
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
}

.card {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.action {
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  margin-bottom: 20px;
}

.face {
  width: 50px;
  height: 50px;
  background-color: #1890ff;
  border-radius: 50%;
}

.face:hover {
  scale: 1.2;
  cursor: pointer;
}
</style>
